import requests

# 定义一个函数来获取当前时间
def get_current_time(url):
    try:
        # 发送 GET 请求到 /time 路由
        response = requests.get(url + '/time')
        # 检查响应的状态码
        if response.status_code == 200:
            # 返回接口返回的数据
            return response.text
        else:
            return f"Error: Received status code {response.status_code}"
    except Exception as e:
        return f"An error occurred: {e}"

# Flask 应用运行在本地的 5000 端口
url = 'http://127.0.0.1:5000'

# 调用函数并打印结果
current_time = get_current_time(url)
print(current_time)